<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//Route::get('/', function () {
//    return view('welcome');
//});
//admin后台路由
/**群组路由，可以将公共部分提出来公用
 * middleware中间件
 * prefix路由前缀
 * as别名
 * namespace命名空间
 * Controllers/admin/HomeController
 */
Route::group(['middleware'=>['admin.auth'],'prefix'=>'admin','as'=>'admin.','namespace'=>'Admin'],function (){
        Route::get('/','HomeController@index')->name('home.index');

});
Route::group(['middleware'=>['admin.auth'],'prefix'=>'admin','as'=>'admin.','namespace'=>'Admin'],function (){
    Route::resource('column','ColumnController');
    Route::any('column/destroy/{column}','ColumnController@destroy')->name('column.destroy');
    Route::any('column/edit/{column}','ColumnController@edit')->name('column.edit');

});

//-------------------------------------------------------------------------------------------------------
//共公前台路由
/**
 *Controllers/Home/CommentController
 */
Route::group(['namespace'=>'Common','prefix'=>'common','as'=>'common.'],function(){
    Route::get('/comment/make','CommentController@make')->name('comment.make');
    Route::resource('comment','CommentController');

});
Route::group(['namespace'=>'Common','prefix'=>'common/zan','as'=>'common.zan.'],function(){
    Route::get('/make','ZanController@make')->name('make');
});
Route::group(['namespace'=>'Common','prefix'=>'common/favorite','as'=>'common.favorite.'],function(){
    Route::get('/make','FavoriteController@make')->name('make');
});

//前台类路由
/**
 *Controllers/Home/IndexController
 */
Route::group(['namespace'=>'Home','as'=>'home.'],function(){

    Route::get('/','IndexController@index')->name('index.index');

});
Route::group(['namespace'=>'Home','as'=>'home.'],function (){
    Route::get('search','SearcheController@index')->name('search');
    Route::get('search/seacherd','SearcheController@seacherd')->name('search.seacherd');
});
/**
 * Controllers/Home/LoginController
 */
Route::group(['namespace'=>'Home','prefix'=>'home/login/','as'=>'home.login.'],function(){

    Route::get('/login','LoginController@login')->name('login');
    Route::post('/store','LoginController@store')->name('store');
    Route::get('/logout','LoginController@logout')->name('logout');

});
/**
 * Controllers/Home/UserController
 */
Route::group(['namespace'=>'Home','prefix'=>'home/user/','as'=>'home.user.'],function(){

    Route::get('/create','UserController@create')->name('create');
    Route::post('/store','UserController@store')->name('store');
    Route::any('/attentions/{user}','UserController@attentions')->name('attentions');
});
//-------------------------权限管理控制器------------------
Route::group(['namespace'=>'Permission','prefix'=>'permission/','as'=>'permission.'],function(){

    Route::resource('/role','RoleController');
    Route::get('/role/setPermission/{user}','RoleController@setRole')->name('role.setPermission');
    Route::post('/role/setingPermission/{user}','RoleController@setingRole')->name('role.setingPermission');



    Route::resource('/permission','PermissionController');
    Route::get('/permission/setPermission/{role}','PermissionController@setPermission')->name('permission.setPermission');
    Route::post('/permission/setingPermission/{role}','PermissionController@setingPermission')->name('permission.setingPermission');


    Route::resource('/module','ModuleController');
    Route::resource('/user','UserController');

});


/**
 * Controllers/Home/AtticleController
 */
Route::group(['namespace'=>'Home','prefix'=>'home/article','as'=>'home.article.'],function (){
    Route::any('index','ArticleController@index')->name('index');
    Route::any('create','ArticleController@create')->name('create');
    Route::any('store','ArticleController@store')->name('store');
    Route::any('show/{article}','ArticleController@show')->name('show');
    Route::any('edit/{article}','ArticleController@edit')->name('edit');
    Route::any('update/{article}','ArticleController@update')->name('update');
    Route::any('destroy/{article}','ArticleController@destroy')->name('destroy');
//    Route::any('zans/{article}','ArticleController@zans')->name('zans');
    Route::any('favorite/{article}','ArticleController@favorite')->name('favorite');

});

Route::group(['namespace'=>'Home','prefix'=>'home/','as'=>'home.'],function(){

Route::resource('topic','TopicController');
});
Route::group(['namespace'=>'Home','prefix'=>'home/','as'=>'home.'],function(){
    Route::any('/lesson/lists','LessonController@lists')->name('lesson.lists');

    Route::resource('lesson','LessonController');


});


//---------------------------------------------------------------------------------------------------
/**
 * 工具类路由
 * 1.验证管理控制器Controller/Util/CodeController
 */

Route::group(['namespace'=>'Util','prefix'=>'util/code/','as'=>'util.code.'],function(){

    Route::any('/send','CodeController@send')->name('send');

});
//配置项类
Route::group(['namespace'=>'Admin','prefix'=>'admin/config/','as'=>'admin.config.'],function (){
    Route::get('/edit/{name}','ConfigController@edit')->name('edit');
    Route::post('/update/{name}','ConfigController@update')->name('update');
    Route::get('/show_template','ConfigController@show_template')->name('show_template');
    Route::get('/set_template/{theme}','ConfigController@set_template')->name('set_template');
    //做加载更换模板的测试方法
    Route::get('/testTemplate','ConfigController@testTemplate')->name('testTemplate');
});
//会员中心控制组
Route::group(['namespace'=>'Member','prefix'=>'member/user/','as'=>'member.user.','middleware'=>['auth'],],function (){
   Route::get('/index','UserController@index')->name('index');
   Route::get('/create','UserController@create')->name('create');
   Route::any('/update/{user}','UserController@update')->name('update');
});
Route::group(['namespace'=>'Member','prefix'=>'member/','as'=>'member.','middleware'=>['auth'],],function (){
    Route::resource('article','ArticleController');
});
Route::group(['namespace'=>'Member','prefix'=>'member/','as'=>'member.','middleware'=>['auth'],],function (){
    Route::resource('message','MessageController');
    Route::get('message/destroy/{id}','MessageController@destroy')->name('message.destroy');
});
//上传类的控制类路由
Route::group(['middleware'=>['auth'],'namespace'=>'Util','prefix'=>'util/upload/','as'=>'util.upload.'],function (){
    Route::any('/upload','UploadController@upload')->name('upload');
    Route::any('/lists','UploadController@lists')->name('lists');
});
//------------------------------------微信配置---------------------------------------------------------//
Route::group(['namespace'=>'Wechat','prefix'=>'wechat/api/','as'=>'wechat.api.'],function (){
    Route::any('handler','ApiController@handler')->name('handler');
});
Route::group(['namespace'=>'Wechat','prefix'=>'wechat/','as'=>'wechat.'],function (){
    Route::resource('reply','ReplyController');
});
Route::group(['namespace'=>'Wechat','prefix'=>'wechat/','as'=>'wechat.'],function (){
    Route::resource('wxbutton','WxButtonController');
    Route::get('wxbutton/push/{wxButton}','WxButtonController@push')->name('wxbutton.push');
});
Route::group(['namespace'=>'Wechat','prefix'=>'wechat/','as'=>'wechat.'],function (){
    Route::resource('/wxReply','WxReplyController');
});
Route::group(['namespace'=>'Wechat','prefix'=>'wechat/','as'=>'wechat.'],function (){
    Route::resource('/wxImage','WxImageController');
});
//------------------------------------新闻配置---------------------------------------------------------//
Route::group(['namespace'=>'News','prefix'=>'news/','as'=>'news.'],function (){
    Route::resource('/classify','ClassifyController');

});
Route::group(['namespace'=>'News','prefix'=>'news/','as'=>'news.'],function (){
    Route::get('/news/lists','NewsController@lists')->name('lists');
    Route::get('/news/classify/{classify}','NewsController@classify')->name('classify');
    Route::resource('/news','NewsController');

});